<?php
require_once 'Response.php';
require_once 'DB.php';

$user = (array)json_decode(file_get_contents( "php://input"));

$user['create_time'] = time();

//2. 存入数据库
$sql = "INSERT `user` (username,password,address,telephone) VALUES ('".$user['username']."', {$user['password']}, {$user['address']}, '".$user['tel']."')";
$pdo = DB::getInstance()->connect();
$count  =  $pdo->exec($sql); //返回受影响的行数

//3. 结果返回
Response::json(200, '添加成功！', ['id'=>$pdo->lastInsertId()]);